<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.shoeshopping.entity.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
			
	User currentUser = ((User) session.getAttribute("user"));
	String username = null;
	if (currentUser != null) {
		username = currentUser.getUsername();
	}
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>我的购物车</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel='stylesheet' type='text/css' />
<link href="css/bootstrap.min.css" rel='stylesheet' type='text/css' />

<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
</script>
<!----webfonts---->
<link href='css/css.css?family=Open+Sans:400,300,600,700,800'
	rel='stylesheet' type='text/css'>
<!----//webfonts---->
<script src="js/jquery.min.js"></script>
<!----start-alert-scroller---->
<script type="text/javascript" src="js/jquery.easy-ticker.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('#demo').hide();
		$('.vticker').easyTicker();
	});
</script>
<!----start-alert-scroller---->
<!-- start menu -->
<link href="css/megamenu.css" rel="stylesheet" type="text/css"
	media="all" />
<script type="text/javascript" src="js/megamenu.js"></script>
<script>
	$(document).ready(function() {
		$(".megamenu").megamenu();
	});
</script>
<script src="js/menu_jquery.js"></script>
<!-- //End menu -->
<!---move-top-top---->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
	jQuery(document).ready(function($) {
		$(".scroll").click(function(event) {
			event.preventDefault();
			$('html,body').animate({
				scrollTop : $(this.hash).offset().top
			}, 1200);
		});
	});
</script>
<!---//move-top-top---->
</head>
<body>
	<!---start-wrap---->
	<!---start-header---->
	<div class="header">
		<%
			//jsp include进 top-header
		%>
		<jsp:include page="/component/top-header.jsp" flush="true">
			<jsp:param value='<%=username %>' name="username" />
		</jsp:include>

		<%
			//jsp include进 middle-header
		%>
		<jsp:include page="/component/middle-header.jsp" flush="true" />

		<%
			//jsp include进 middle-header
		%>
		<jsp:include page="/component/bottom-header.jsp" flush="true" />

		<div class="clear"></div>
	</div>
	<div class="content contact-main">
		<div class="contact-info">
			<div class="container">
				<div class="row">
					<div class="col-md-3"></div>
					<div class="col-md-6">
						<table class="table table-hover table-striped">
							<thead>
								<td>商品编号</td>
								<td>商品名</td>
								<td>数量(双)</td>
								<td>价格(元)</td>
								<td>操作</td>
							</thead>
							<tbody>
								<%
									User user = (User)session.getAttribute("user");
									List<DeliveryAddress> daList = user.getAddresses();
									List giList = (List) session.getAttribute("goodsItemList");
									if(giList != null && giList.size() > 0) {
										GoodsItem gi = (GoodsItem)giList.get(0);
										for (int i = 1; i <= giList.size(); i++) {
											GoodsItem goodsItem = (GoodsItem) giList.get(i-1);
								%>
								
								<tr>
									<td><%= goodsItem.getGoods().getId() %></td>
									<td><%= goodsItem.getGoods().getName() %></td>
									<td><%= goodsItem.getNum() %></td>
									<td><%= goodsItem.getGoods().getPrice() %></td>
									<td>
										<a href="user/cart_Delete.action?goodsItem.id=<%=goodsItem.getId()%>
										&goodsItem.shoppingCart.id=<%=goodsItem.getShoppingCart().getId()%>">
										<button class="btn btn-default" style="">删除</button></a>

									</td>
								</tr>
								<%
									}}
								%>
							</tbody>
						</table>
					</div>
				</div>
				<div class="row">
					<div class="col-md-3"></div>
					<div class="col-md-6">
						<button class="btn btn-danger" data-toggle="modal"
							data-target="#myModal" style="float: right;">提交订单</button>
					</div>
				</div>
				<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<!-- /.modal -->
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">&times;</button>
								<h4 class="modal-title" id="myModalLabel">Modal title</h4>
							</div>
							<% if(giList != null && giList.size() > 0)  {
								GoodsItem gi = (GoodsItem)giList.get(0);
							%>
							<div class="modal-body">
								<form role="form" action="user/order_save">
								<%
									if(daList != null && daList.size() > 0) {
										for(Iterator it = daList.iterator();it.hasNext();) {
											DeliveryAddress da = (DeliveryAddress)it.next();
								 %>
									<div class="radio">
                                        <label>
                                            <input type="radio" name="otherAdd" value="<%=da.getId()%>" checked>
                                              	收货人：<%=da.getName() %>
                                              	收货地址：<%=da.getAddress() %>
                                              	收货人电话号码：<%=da.getPhone() %>
                                        </label>
                                    </div>
                               <%}} %>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="otherAdd" value="other">
                                         	  其它
                                        </label>
                                    </div>
								
									<input type="hidden" 
										   value="<%=gi.getNum()%>"
									       name="orderItem.num">
									<div class="form-group">
										<label>收货人</label> <input class="form-control" type="text" 
										name="deliveryAddress.name"/>
									</div>
									<div class="form-group">
										<label>地址</label> <input class="form-control" type="text" 
										name="deliveryAddress.address"/>
									</div>
									<div class="form-group">
										<label>电话</label> <input class="form-control" type="text" 
										name="deliveryAddress.phone"/>
									</div>
									<input type="submit" class="btn btn-danger"
										style="float: right;" value="购 买" />
								</form>
							</div><% } %>
							<div class="modal-footer"></div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal-dialog -->
				</div>
			</div>

		</div>
	</div>
	</div>

</body>
</html>

